<template>
  <div class="common-layout">
    <el-container>
      <el-aside width="300px" >

        <div>
          <el-table :data="studentMsgList" @cell-click="selStuMsg" height="250" style="width: 100%">

            <el-table-column prop="stuName"  label="未读消息列表" width="180" >
              <template #default="scope">

              </template>

            </el-table-column>
          </el-table>
        </div>
        <div>
          <el-table :data="studentName" @cell-click="selStu" height="250" style="width: 100%">

            <el-table-column prop="stuName"  label="学生名" width="180" />


<!--            <el-table-column prop="stuName"  label="" width="180" >-->
<!--              <template #default="scope">-->
<!--                                <el-badge value="new" class="item">-->

<!--                                </el-badge>-->
<!--              </template>-->

<!--            </el-table-column>-->
          </el-table>
        </div>

        </el-aside>
      <el-main>
        <router-view></router-view>

      </el-main>
    </el-container>
  </div>
</template>

<script>
import {Search} from "@element-plus/icons-vue";
import {useLoginStateStore} from "../../store/storeLoginState.js";

export default {
  name: "AnsQuestion",
  setup(){
    const loginStateStore = useLoginStateStore()
    return {
      loginStateStore: loginStateStore,
      Search
    }
  },
  data(){
    return{
      contactsName:"",
      studentMsgList:[

      ],
      studentName:[
        // {
        //   stuName:'',
        //   stuNum:'',
        // }
      ],
      teacher:[
        {
          teaName:'',
          teaNum:'',
        }
      ],

    }
  },
  mounted() {
    this.searchStu();
    this.selStuList();



  },
  methods: {
    selStuList(){
      let _this=this;
      let teaNum=window.sessionStorage.getItem("userNum")
      let url1="/studyadmin/student/stuSendMsg";
      _this.$axios.get(url1,{params:{teaNum:teaNum}}).then(function (serverData) {

        if (serverData.data.code === 0) {
          console.log("学生消息数据：", serverData.data.data)
          _this.studentMsgList=serverData.data.data

        }
      })
    },
    searchStu(){
      let _this=this;
      let url="/studyadmin/student/stulist";
      _this.$axios.post(url).then(function (serverData) {
        console.log("学生内容数据：", serverData.data.data)
        if (serverData.data.code == 0) {
          _this.studentName=serverData.data.data
          // for (let i=0;i<serverData.data.data.length;i++){
          //   let s=serverData.data.data;
          //   // console.log("klklk",serverData.data.data[i].stuNum)
          //   if(stuNum!==serverData.data.data[i].stuNum){
          //
          //     _this.studentName.push({stuName:s[i].stuName,stuNum:s[i].stuNum,name:s[i].teaName})
          //   }
          // }
        }
      })

    },
    //选择要联系的学生并将消息设置成已读
    selStu(row){
      // console.log("----------------",row)
      // alert("0000")
      let _this=this
      _this.$router.push({name:'TeaQuestionAns',query: {receiveNum:row.stuNum,name:row.stuName},replace:true})
      //
    },
    selStuMsg(row){
      let _this=this
      let teaNum=window.sessionStorage.getItem("userNum")
      let url1="/studyadmin/message/MsgRead";
      _this.$axios.get(url1,{params:{teaNum:teaNum,stuNum:row.stuNum}}).then(function (serverData) {

        if (serverData.data.code === 0) {
        }
      })

      _this.$router.push({name:'TeaQuestionAns',query: {receiveNum:row.stuNum,name:row.stuName},replace:true})

    },


    // selTea(){
    //   // console.log(row.teaNum)
    //   let _this=this
    //   _this.$router.push({name:'TeaQuestionAns',query: {receiveNum:row.teaNum,name:row.teaName},replace:true})
    //
    // }


  },


}
</script>

<style scoped>

</style>
